package study.designpattern.mediator;

import java.awt.HeadlessException;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JFrame;
import javax.swing.JPanel;

public class MainMediator extends JFrame implements ActionListener {
    IMediator med = new Mediator();
    
    public MainMediator() throws HeadlessException {
        JPanel panel = new JPanel();
        panel.add(new BtnView(this, med));
        panel.add(new BtnBook(this, med));
        panel.add(new BtnSearch(this, med));
        getContentPane().add(new LblDisplay(med), "North");
        getContentPane().add(panel, "South");
        setSize(400, 200);
        setVisible(true);
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        Command comd = (Command) e.getSource();
        comd.execute();
    }
    public static void main(String[] args) {
        new MainMediator();
    }
}
